import { BASE_URL, TIME_OUT } from "./config"
import localCach from "./localCach"
import XtRequest from "./config/request"
export default new XtRequest({
  baseURL: BASE_URL,
  timeout: TIME_OUT,

  interceptors: {
    requestSuccess: (config: any) => {
      // 设置请求头
      const token = localCach.getCach("token")
      if (token) {
        config.headers.Authorization = `Bearer ${token}`
      }
      console.log(BASE_URL)
      return config
    },
    requestFail: (err) => {
      console.log("请求拦截失败")
      return err
    },
    responseSuccess: (res) => {
      console.log("响应拦截成功")
      return res.data
    },
    responseFail: (err) => {
      console.log("响应拦截失败")
      return err
    },
  },
})
